<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 

/*************************************************************
  Edison VLE - EDucatIonal SOcial Networking
  
  @file: /system/application/libraries/Theme.php
  @usage: Contains functionality for themes, and processing
          the {tags} within them
  @last-major-update: 22:21 09/11/2008
  
  ©2008 Daniel Wood and the Edison group, all rights reserved.
  This header must stay intact for legal use. If you make changes
  to this file or any of the others within the Edison software,
  you are required to make these changes publicly available.
*************************************************************/

class Theme {

	var $CI;

	function Theme()
	{
		// Get CI instance
		$this->CI =& get_instance();
		
		// Ensure DB config values are loaded
		$this->CI->config->db_config_fetch();
		
		// Load Menu library
		$this->CI->load->library('menu');
	}
	
	/**
	  * _showHeader - Take the relevant header.php file from the config theme value,
	  * then process it and return as String.
	  *
	  * @author Daniel Wood
	  * @return String containing the processed header, or empty string on fail.
	  **/
	function _showHeader()
	{
		$appMenuData = $this->CI->menu->_appMenuArray();
		$siteMenuData = $this->CI->menu->_siteMenuArray();
		
		//exit(nl2br(var_dump($siteMenuData)));		
		
		$data = array(
			'site-meta-info' => $this->CI->config->item('site-meta-info'),
			'site-title' => $this->CI->config->item('site-title'),
			'site-powered-by' => $this->CI->config->item('site-powered-by'),
			'site-header-includes' => $this->CI->config->item('site-header-includes'),
			'site-tagline' => $this->CI->config->item('site-tagline'),
			'application-menu' => $appMenuData,
			'site-menu' => $siteMenuData
		);
		return $this->CI->parser->parse('themes/'.$this->CI->config->item('site-theme').'/header', $data, TRUE);
	}
	
	/**
	 * _showFooter - Take the relevant footer.php file from the config theme value,
	 * the process it and return as String.
	 *
	 * @author Daniel Wood
	 * @return String containing the processed footer, or empty string on fail.
	 **/
	function _showFooter()
	{
		$data = array(
			'site-affiliates' => $this->CI->config->item('site-affiliates'),
			'site-copyright' => $this->CI->config->item('site-copyright')
		);
		return $this->CI->parser->parse('themes/'.$this->CI->config->item('site-theme').'/footer', $data, TRUE);
	}
	
}

/* End of file Theme.php */
/* Location: ./system/application/libraries/Theme.php */